package MailBox;

public class KotakSurat {
	private Integer isi= 0;
	
	public synchronized void masukkan() throws InterruptedException{
		if(isi!=0){
			System.out.println("Kotak masih ada isinya, menunggu dikosongkan");
			wait();
		}
		System.out.println("Surat Dimasukkan");
		isi++;
		notifyAll();//
	}
	
	public synchronized void ambil()throws InterruptedException{
		if(isi==0){
			System.out.println("Kotak tidak ada isinya, menunggu diisi");
			wait();
		}
		
		System.out.println("Surat Diambil");
		isi--;
		notifyAll();//
	}
	
	public synchronized Integer jumlah(){
		return isi;
	}
	
}
